<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="/extjs/include/all.jsp"%>


<html>
 <head>
  <title>子菜单列表</title>
 </head>
<%
 	String id = (String)request.getParameter("parentId");
 	if(id == null || "".equals(id)){
 		id = (String)request.getParameter("id");
 	}
	String symbolicName = (String)request.getParameter("symbolicName");
  //String menuType = (String)request.getParameter("menuType");
%>
 <body>
   <script>
   Ext.onReady(function(){
   
   	var menuListStore = new Ext.data.JsonStore({
		url: '${pageContext.request.contextPath}/edu.ccut.saturn.manager.menu.impl::/extMenuModule/action/GetChildMenuList.action?id=<%=id%>&symbolicName=<%=symbolicName%>&menuType=child',
		root: 'childMenuItemList',
		fields: [
			{name:'id'},
			{name:'label'},
			{name:'symbolicName'},
			{name:'path'},
			{name:'childSize'},
			{name:'parentId'}
		]
	});   
	menuListStore.load();
	
	var resultWidth = Ext.get("showChildMenu").getWidth();
	var cm = new Ext.grid.ColumnModel([ 
	    new Ext.grid.RowNumberer(), 
        {header:'菜单名称',dataIndex:'label',width:resultWidth*0.25,renderer:function(value, p, record){
        	if(record.data.childSize == 0){
        		return value;
        	} else {
	        	return String.format("<a href=\"${pageContext.request.contextPath}/edu.ccut.saturn.manager.menu.impl/extMenuModule/page/childMenuItemList.jsp?id={1}&symbolicName={2}\">{0}</a>", 
		        		value,record.data.id,record.data.symbolicName
       					);
       		}
        }}, 
        {header:'bundle名称',dataIndex:'symbolicName',width:resultWidth*0.25}, 
        {header:'菜单路径',dataIndex:'path',width:resultWidth*0.25},
        {header:'操作',dataIndex:'id',width:resultWidth*0.25,renderer:function(value, p, record){
        	return String.format("<a href=\"${pageContext.request.contextPath}/edu.ccut.saturn.manager.menu.impl::/menuModule/action/MenuItemUptoFirst.action?id={0}&parentId={2}&symbolicName={1}&&menuType=child\">最上</a>&nbsp;&nbsp;"+
        	"<a href=\"${pageContext.request.contextPath}/edu.ccut.saturn.manager.menu.impl::/menuModule/action/MenuItemUp.action?id={0}&parentId={2}&symbolicName={1}&&menuType=child\">上移</a>&nbsp;&nbsp;"+
	        "<a href=\"${pageContext.request.contextPath}/edu.ccut.saturn.manager.menu.impl::/menuModule/action/MenuItemDown.action?id={0}&parentId={2}&symbolicName={1}&&menuType=child\">下移</a>&nbsp;&nbsp;"+
	        "<a href=\"${pageContext.request.contextPath}/edu.ccut.saturn.manager.menu.impl::/menuModule/action/MenuItemDowntoLast.action?id={0}&parentId={2}&symbolicName={1}&&menuType=child\">最下</a>",		
	        		value,record.data.symbolicName,record.data.parentId);}
        }
    ]); 
    cm.defaultSortable = false; 
       
	var grid = new Ext.grid.GridPanel({ 
	    el:'showChildMenu', 
	    title:'子菜单列表', 
	 //   height:600, 
	    autoHeight:true,
	    collapsible:true,
	    stripeRows: true,
	    collapsible:true,
	    bodyStyle:'width:100%',
	    trackMouseOver:false, 
	    loadMask: {msg:'正在加载数据，请稍侯……'}, 
	    store:menuListStore, 
	    cm: cm,
	     tbar: [{
            text:'返回',
            tooltip:'返回',
        //    iconCls:'back',
            handler: function(){
            	window.location = '${pageContext.request.contextPath}/edu.ccut.saturn.manager.menu.impl/extMenuModule/page/rootMenuItemList.jsp?';
            }
        }]
	    
	}); 
    grid.render(); 	
});
   </script>

  <div id="showChildMenu" style="width:100%"></div>
 </body>
 </html>
